variables:
  - &alpine_image 'docker.io/alpine:3.19'
  - path: &docs_path
      include: ['doc/**', 'mkdocs.yml']

steps:
  docker-build-image:
    image: woodpeckerci/plugin-docker-buildx:latest
    settings:
      dockerfile: Dockerfile
      repo: vnpower/pixivfe
      username:
        from_secret: DOCKER_USERNAME
      password:
        from_secret: DOCKER_PASSWORD
      auto_tag: true
    when:
      branch: [ v2 ]
      event: [ tag, release, manual ]

  generate-docs:
    image: woodpeckerci/plugin-mkdocs:latest
    settings:
      verbose: true
      pip_install_file: doc/requirements.txt
    when:
      - event: push
        path: *docs_path
        branch: [ v2 ]
      - event: [ tag, release, manual ]

  deploy-docs-cloudflare:
    image: *alpine_image
    environment:
      CLOUDFLARE_ACCOUNT_ID:
        from_secret: CLOUDFLARE_ACCOUNT_ID
      CLOUDFLARE_API_TOKEN:
        from_secret: CLOUDFLARE_API_TOKEN
    commands:
      - apk add npm --repository https://dl-cdn.alpinelinux.org/alpine/edge/community/
      - npx wrangler pages deploy site --project-name=pixivfe-docs
    when:
      - event: push
        path: *docs_path
        branch: [ v2 ]
      - event: [ tag, release, manual ]
    depends_on:
      - generate-docs
